package com.cssy.xxkj.logic.dao.impl;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.cssy.xxkj.logic.dao.LogicWarehouseDetailsDAO;
import com.cssy.xxkj.logic.entity.LogicWarehouseDetailsDO;
import com.cssy.xxkj.logic.entity.vo.LogicPurchaseWareSumVO;
import com.cssy.xxkj.logic.entity.vo.LogicWarehouseDetailsVO;
import com.cssy.xxkj.logic.entity.vo.LogicWarehouseEndMonthSumVO;
import com.plat.helper.SearchConditions;

/**
 * 数据访问对象实现类
 * @since 2014-09-16
 */
public class LogicWarehouseDetailsDAOImpl extends SqlMapClientDaoSupport implements LogicWarehouseDetailsDAO {

    /**
     * 插入数据
     * @param logicWarehouseDetailsDO
     * @return 插入数据的主键
     */
    public String insertLogicWarehouseDetailsDO(LogicWarehouseDetailsDO logicWarehouseDetailsDO) {
        Object id = getSqlMapClientTemplate().insert("LogicWarehouseDetails.insert", logicWarehouseDetailsDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicWarehouseDetailsDO
     * @return 查出的记录数
     */
    public Integer countLogicWarehouseDetailsDOByExample(LogicWarehouseDetailsDO logicWarehouseDetailsDO) {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWarehouseDetails.countByDOExample", logicWarehouseDetailsDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicWarehouseDetailsDO
     * @return 受影响的行数
     */
    public Integer updateLogicWarehouseDetailsDO(LogicWarehouseDetailsDO logicWarehouseDetailsDO) {
        int result = getSqlMapClientTemplate().update("LogicWarehouseDetails.update", logicWarehouseDetailsDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicWarehouseDetailsDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicWarehouseDetailsDO> findListByExample(LogicWarehouseDetailsDO logicWarehouseDetailsDO) {
        List<LogicWarehouseDetailsDO> list = getSqlMapClientTemplate().queryForList("LogicWarehouseDetails.findListByDO", logicWarehouseDetailsDO);
        return list;
    }

    /**
     * 根据主键获取logicWarehouseDetailsDO
     * @param id
     * @return logicWarehouseDetailsDO
     */
    public LogicWarehouseDetailsDO findLogicWarehouseDetailsDOByPrimaryKey(String id) {
        LogicWarehouseDetailsDO logicWarehouseDetailsDO = (LogicWarehouseDetailsDO) getSqlMapClientTemplate().queryForObject("LogicWarehouseDetails.findByPrimaryKey", id);
        return logicWarehouseDetailsDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicWarehouseDetailsDOByPrimaryKey(String id) {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicWarehouseDetails.deleteByPrimaryKey", id);
        return rows;
    }

	@Override
	public List<LogicWarehouseDetailsDO> find(SearchConditions scs) throws DataAccessException {
		List<LogicWarehouseDetailsDO> list = getSqlMapClientTemplate().queryForList("LogicWarehouseDetails_ex.find", scs);
        return list;
	}

	@Override
	public Integer count(SearchConditions scs) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWarehouseDetails_ex.count", scs);
        return count;
	}

	@Override
	public Integer deleteBizRemoved(String id) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWarehouseDetails_ex.deleteBizRemoved", id);
        return count;
	}

	@Override
	public List<LogicWarehouseDetailsVO> findDaliyReport(SearchConditions scs) {
		List<LogicWarehouseDetailsVO> list = getSqlMapClientTemplate().queryForList("LogicWarehouseDetails_ex.findDaliyReport", scs);
        return list;
	}

	@Override
	public Integer findDaliyReportCount(SearchConditions scs) {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWarehouseDetails_ex.findDaliyReportCount", scs);
        return count;
	}
	
	/**
	 * 采购入库汇总统计报表
	 */
	@Override
	public List<LogicPurchaseWareSumVO> findQueryPcswToSummary(SearchConditions scs){
		List<LogicPurchaseWareSumVO> list = getSqlMapClientTemplate().queryForList("LogicWarehouseDetails_ex.findQueryPcswToSummary", scs);
        return list;
	}
	
	@Override
	public Integer countQueryPcswToSummary(SearchConditions scs){
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWarehouseDetails_ex.countQueryPcswToSummary", scs);
        return count;
	}

	@Override
	public List<LogicWarehouseEndMonthSumVO> findQueryEndMonthToSummary(SearchConditions scs) {
		List<LogicWarehouseEndMonthSumVO> list = getSqlMapClientTemplate().queryForList("LogicWarehouseDetails_ex.findQueryEndMonthToSummary", scs);
		return list;
	}

	@Override
	public Integer countQueryEndMonthToSummary(SearchConditions scs) {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWarehouseDetails_ex.countQueryEndMonthToSummary", scs);
        return count;
	}
}